package com.dhcc.utils;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 具体功能实现于 com.dhcc.utils.map
 * @see java.lang.String String 辅助工具类
 * @author hibean@qq.com 2017年6月28日
 *
 */
@SuppressWarnings("rawtypes")
public class __Map {
	private static final Map<String, String> map;
	private static final Map<String, Operator<Map>> operators;
	static{
		map = UtilUtil.scan("com.dhcc.utils.map");
		operators = new ConcurrentHashMap<String, Operator<Map>>(map.size());
	}
	/**
	 * 执行字符串的操作
	 * @param operator
	 * @param str
	 * @param args
	 * @return
	 */
	public static <T> T op(String operator, Map map, Object... args){
		return UtilUtil.<T, Map>op(__Map.map, operators, operator, map, args);
	}
	
	public static void registry(String name, Class<? extends Operator<String>> clazz){
		UtilUtil.<String>registry(name, clazz, map);
	}

	public static Map map(String fields, Object... values) {
		HashMap<String, Object> map = new HashMap<String, Object>();
		String[] strs = fields.split(",");
		for (int i = 0; i < strs.length; i++) {
			map.put(strs[i], values[i]);
		}
		return map;
	}
}
